package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.controller.request.BookPageRequest;
import com.example.springboot.entity.Person;
import com.example.springboot.service.impl.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author danqihao
 */
@CrossOrigin
@RestController
@RequestMapping("/person")
public class PersonController {
    @Autowired
    private PersonService personService;


    @PostMapping("/save")
    public Result save(@RequestBody Person person) {
        personService.addPerson(person);
        return Result.success();
    }

    @GetMapping("/page")
    public Result page(BookPageRequest pageRequest) {
        return Result.success(personService.page(pageRequest));
    }
}
